package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@Api(tags = "工作台相关接口")
public class WorkSpaceController {

    @Autowired
    private WorkSpaceService workSpaceService;

    /**
     * 查询今日运营数据
     * @return
     */
    @GetMapping("/businessData")
    @ApiOperation(value = "查询今日运营数据")
    public Result<BusinessDataVO> getBusinessData(){
        //今日最小时间
        LocalDateTime beginTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        //今日最大时间
        LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        BusinessDataVO businessData = workSpaceService.getBusinessData(beginTime,endTime);
        return Result.success(businessData);
    }
    /**
     * 套餐总览
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation(value = "套餐总览")
    public Result<SetmealOverViewVO> getOverviewSetmeals(){
        SetmealOverViewVO setmealOverView= workSpaceService.getOverviewSetmeals();
        return Result.success(setmealOverView);
    }
    /**
     * 菜品总览
     */
    @GetMapping("/overviewDishes")
    @ApiOperation(value = "菜品总览")
    public Result<DishOverViewVO> overviewDishes(){
        DishOverViewVO dishOverViewVO = workSpaceService.getOverviewDishes();
        return Result.success(dishOverViewVO);
    }
    /**
     * 订单管理数据
     */
    @GetMapping("/overviewOrders")
    @ApiOperation(value = "订单数据管理")
    public Result<OrderOverViewVO> overviewOrders(){
        OrderOverViewVO orderOverViewVO = workSpaceService.getOverviewOrders();
        return Result.success(orderOverViewVO);
    }

}
